import { BuildConfig } from '@/utils/api-bees';

const apiUrl = (process.env.envVariable as any)['apiUrl'];
const version = process.env.version;

export default (): BuildConfig => {
  const baseUrl = `${apiUrl}`;

  return {
    baseUrl,
    configureOptions(headers) {
      return ({
        ...headers,
        version: version
      })
    },
    // 业务请求成功中间插入点
    afterResolve({ api, data, options }) {
      console.log("请求成功", api, data, options);
      return data;
    },
    afterReject(error) {
      console.error('请求失败', JSON.stringify(error));
      return Promise.reject(error);
    }
  }
}
